
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 1
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 11:14
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int m, n;
    cin >> m >> n;
    int nums[m][n];

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> nums[i][j];
        }
    }

    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < m; ++j) {
            cout << nums[j][i] << " ";
        }
        cout << endl;
    }

    return 0;
}